package com.xiaoxiaoniu.airoleplay.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * 聊天响应数据传输对象
 * 用于封装AI角色回复用户的消息内容
 */
@Setter
@Getter
public class ChatResponse {

    /**
     * AI回复内容
     */
    @JsonProperty("reply")
    private String reply;

    /**
     * 会话ID，用于标识对话上下文
     */
    @JsonProperty("conversation_id")
    private String conversationId;

    /**
     * 响应时间戳
     */
    @JsonProperty("timestamp")
    private long timestamp;

    /**
     * 请求处理是否成功
     */
    @JsonProperty("success")
    private boolean success;

    /**
     * 错误信息，当success为false时包含错误详情
     */
    @JsonProperty("error_message")
    private String errorMessage;

    /**
     * 无参构造函数
     * 默认设置时间戳为当前时间，success为true
     */
    public ChatResponse() {
        this.timestamp = System.currentTimeMillis();
        this.success = true;
    }

    /**
     * 带回复内容的构造函数
     * 
     * @param reply AI回复内容
     */
    public ChatResponse(String reply) {
        this();
        this.reply = reply;
    }

    /**
     * 带回复内容和会话ID的构造函数
     * 
     * @param reply AI回复内容
     * @param conversationId 会话ID
     */
    public ChatResponse(String reply, String conversationId) {
        this();
        this.reply = reply;
        this.conversationId = conversationId;
    }

    /**
     * 带成功状态和错误信息的构造函数
     * 
     * @param success 请求处理是否成功
     * @param errorMessage 错误信息
     */
    public ChatResponse(boolean success, String errorMessage) {
        this.timestamp = System.currentTimeMillis();
        this.success = success;
        this.errorMessage = errorMessage;
    }

    @Override
    public String toString() {
        return "ChatResponse{" +
                "reply='" + reply + '\'' +
                ", conversationId='" + conversationId + '\'' +
                ", timestamp=" + timestamp +
                ", success=" + success +
                ", errorMessage='" + errorMessage + '\'' +
                '}';
    }
}